package org.keco.shape;

public class Point {

	private int x;
	private int y;

	public Point(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int calculateDistance(Point p) {
		return Point.calculateDistance(this, p);
	}

	public static int calculateDistance(Point start, Point end) {
		return (int) Math.sqrt(Math.pow(start.getX() - end.getX(), 2) + Math.pow(start.getY() - end.getY(), 2));
	}

	@Override
	public String toString() {
		return "(" + x + "," + y + ")";
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Point) {
			return this.x == ((Point) obj).getX() && this.y == ((Point) obj).getY();
		}
		return false;
	}

	public boolean isSame(int x, int y) {
		return this.x == x && this.y == y;
	}

	public boolean isSame(Point p) {
		return this.x == p.getX() && this.y == p.getY();
	}
}
